const INFO_KEY = 'smart_mall'
const HISTORY_KEY = 'search_key'

export const setInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}

export const getInfo = () => {
  const res = JSON.parse(localStorage.getItem(INFO_KEY))
  return res || { token: '', userid: '' }
}

export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

export const setHistory = (arr) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(arr))
}

export const getHistory = () => {
  const result = JSON.parse(localStorage.getItem(HISTORY_KEY))
  return result || []
}
